#include "Token.h"


Token::Token()
{
	//ctor
	this->column=0;
	this->line=0;
	this->pstr=0;
	this->type=Token_None;
}

Token::Token(Token *ptoken)
{
	this->column=ptoken->column;
	this->line=ptoken->line;
	this->pstr=ptoken->pstr;
	this->type=ptoken->type;
}

Token::~Token()
{
	//dtor
}

Token *Token::clone()
{
	Token *ptoken;
	ptoken=new Token(this);
	return ptoken;
}

pair<string, TokenType> Token::keyMap[] = {
	{"package",TokenKey_Package},
	{"import",TokenKey_Import},
	{"enum",TokenKey_Enum},
	{"public_enum",TokenKey_Public_Enum},
	{"private_enum",TokenKey_Private_Enum}	,
	{"interface",TokenKey_Interface},
	{"public_interface",TokenKey_Public_Interface	}	,
	{"private_interface",TokenKey_Private_Interface	}	,
	{"class",TokenKey_Class	},
	{"public_class",TokenKey_Public_Class	}	,
	{"private_class",TokenKey_Private_Class	}	,
	{"function",TokenKey_Function},
	{"null",TokenKey_Null}
};


unordered_map<string,TokenType> Token::keySet(keyMap,keyMap+sizeof(keyMap)/sizeof(*keyMap));

void Token::checkKey()
{
    unordered_map<string,TokenType>::iterator iter;
	iter=keySet.find(*pstr);
	if(iter!=keySet.end()){
        type=(*iter).second;
	}
}
